﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TaoBao.HttpHelper;

namespace WebApp.Controllers
{
    public class AccountController : Controller
    {
        // GET: Account
        public ActionResult Index()
        {
            return View();
        }
        HttpHelper http = new HttpHelper();
        public string GetToken()
        {
            string url = "https://api.weixin.qq.com/cgi-bin/token";
            string grant_type = "client_credential";
            string appid = ConfigurationManager.AppSettings["appid"];
            string secret = ConfigurationManager.AppSettings["appsecret"];
            string requestUrl = $"{url}?appid={appid}&grant_type={grant_type}&secret={secret}";
            HttpItem item=new HttpItem()
            {
                Method = "get",
                URL = requestUrl
            };
            HttpResult result = http.GetHtml(item);
            return result.Html;
        }
    }
}